import {onMounted, ref} from "vue";
import {useRoute} from "vue-router/dist/vue-router";
import {getCategoryApi} from "@/apis/category";

export function useCategory () {
    let categoryData = ref({})
    let route = useRoute()
    let getCategory = async (id = route.params.id) => {
        const res = await getCategoryApi(id)
        categoryData.value = res.result
    }
    onMounted(() => {
        getCategory()
    })

    return {
        categoryData,
        getCategory
    }
}
